package com.zoshine.zzg.controller;

import com.zoshine.zzg.base.BaseResponse;
import com.zoshine.zzg.pojo.SupplierDetail;
import com.zoshine.zzg.respons.AppResponse;
import com.zoshine.zzg.service.SupplierDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 田沛凌
 * @time 2017/7/17 10:06
 */
@RestController
@RequestMapping(value = "/supplierDetail",method = RequestMethod.POST)
public class SupplierDetailController {

    private SupplierDetailService supplierDetailService;
    @Autowired
    public void setSupplierDetailService(SupplierDetailService supplierDetailService) {
        this.supplierDetailService = supplierDetailService;
    }

    /**
     * 获取供应商详情
     * @param id
     * @return
     */
    @RequestMapping("/getSupplierDetail")
    public BaseResponse getSupplierDetail(Long id){
        SupplierDetail supplierDetail = supplierDetailService.get(id);
        return new AppResponse(supplierDetail);
    }

    /**
     * 删除供应商详情
     * @param id
     * @return
     */
    @RequestMapping("/delSupplierDetail")
    public BaseResponse delSupplierDetail(Long id){
    supplierDetailService.del(id);
        return AppResponse.OK;
    }

    /**
     * 修改供应商详情
     * @param supplierDetail
     * @return
     */
    @RequestMapping("/editSupplierDetail")
    public BaseResponse editSupplierDetail(SupplierDetail supplierDetail){
    supplierDetailService.edit(supplierDetail);
    return AppResponse.OK;
    }

    /**
     * 新增供应商详情
     * @param supplierDetail
     * @return
     */
    @RequestMapping("/addSupplierDetail")
    public BaseResponse addSupplierDetail(SupplierDetail supplierDetail){
    supplierDetailService.add(supplierDetail);
    return AppResponse.OK;
    }
}
